package org.stone.project.tx.pojo.dto;

import cn.hutool.core.util.ObjectUtil;
import lombok.Data;

@Data
public class Result <T>{
    /**
     * 系统状态码
     */
    private int code;

    /**
     * 错误消息
     */
    private String msg;

    /**
     * 响应数据
     */
    private T data;

    /**
     * 请求id
     */
    private String requestId;

    public static <T> Result<T> ok(T data){
        Result<T> res = new Result();
        res.setCode(200);
        res.setData(data);
        return res;
    }

    public static <T> Result<T> ok(){
        Result<T> res = new Result();
        res.setCode(200);
        res.setData(null);
        return res;
    }

    public static Result<String> fail(String msg){
        Result<String> res = new Result();
        res.setCode(0);
        res.setMsg(msg);
        return res;
    }
}
